/*
[编程题]视野争夺(0.2)
time:20210319 22:29 PM
key:1.复杂读O(N),由于编号特性是不重复的数字，开一个巨大一维int数组，全部置0。采用哈希的手段将编号作为下标，读到编号就在对应下表+1.最后遍历这个大数组。
user：ldc
*/
const int max1 = 1001;
int main()
{

	int i, j, n, x, m;
	cin >> n;
	int A[max1] = { 0 };
	for (i = 0; i < n; i++)
	{
		cin >> m;
		for (j = 0; j < m; j++)
		{
			cin >> x;
			A[x]++;
		}
	}
	int g = 0;
	int ii;
	for (i = 0; i < max1; i++)
	{
		if (A[i] >= g)
		{
			g = A[i];
			ii = i;
		}
	}
	cout << ii << " " << g;

}